import { defineStore } from 'pinia'
import { getListApi, postSaveApi, getDeleteApi } from "@/api/users"

export const useUserStore = defineStore('User', {

    state: () => {
        return {
            list: [],
            query1: "",
            query2: "",
            query3: "",
            query4: "",
            query5: "",
            query6: "",
            currentPage: 1,
            pageSize: 3,
            total: ''
        }
    },

    actions: {
        async getList() {
            const { data, total } = await getListApi({
                query1: this.query1,
                query2: this.query2,
                query3: this.query3,
                query4: this.query4,
                query5: this.query5,
                query6: this.query6,
                currentPage: this.currentPage - 1,
                pageSize: this.pageSize
            })
            this.list = data
            this.total = total
        },
        async postSaveApi(data: object) {
            await postSaveApi(data)
        },
        async getDelete({ id }) {
            await getDeleteApi({ id })
        }
    },

    getters: {

    }
})